#ifndef C_DX_MESHMANAGER_H_
#define C_DX_MESHMANAGER_H_

// The include files for Direct3D9
#include <d3d9.h>
#include <d3dx9.h>

#include <vector>

#include "CDXMesh.h"

class CDXMeshManager
{
private:
	std::vector<IDXMesh*>	m_meshes;
	char					m_Dir[MAX_PATH];
	IDirect3DDevice9*		m_pDevice;

	//Singleton Instance
	static CDXMeshManager	m_instance;

	//Trilogy of Evil
	//Constructor (DEACTIVATED)
	CDXMeshManager();
	//Copy Constructor (DEACTIVATED)
	CDXMeshManager(const CDXMeshManager&);
	//Destructor (DEACTIVATED)
	~CDXMeshManager();
	//Assignment Operator (DEACTIVATED)
	CDXMeshManager&	operator=(const CDXMeshManager&);

	//Definition for CDXMesh Iterator
	typedef std::vector<IDXMesh*>::iterator	MeshIter;
public:

	friend class IDXMesh;
	friend class CDXDirectXMesh;
	friend class CDXUserMesh;

	enum DXPRIMITIVEMESH 
	{
		DXPRIM_CUBE,
		DXPRIM_TEAPOT,
		DXPRIM_CYL,
		DXPRIM_SPHERE,
		DXPRIM_TORUS,
		DXPRIM_POLY
	};

	static CDXMeshManager* GetInstance()	{	return &m_instance;	}

	bool Init(char* szMeshDirectory, IDirect3DDevice9* pDXDevice);

	bool Shutdown();

	int	LoadNewDirectXMesh(char* FileName);

	int LoadUserDefinedMesh(CDXUserMesh* userMesh);

	void UnloadMesh(UINT nID);

	//int CreateCubeMesh();
	//int CreateTeapot();
	//int CreateCylinder();
	//int CreateSphere();
	//int CreateTorus();
	//int CreatePolygon();

	// Accessors
	char* GetDirectory(void)		{	return m_Dir;	}
	IDXMesh* GetMeshByID(int MeshID);
	IDXMesh* GetMeshByName(char* MeshName);

	// Mutator
	void SetDirectory(char* szDir)	{	strcpy_s(m_Dir, MAX_PATH, szDir);	}

};
#endif